{template 'common/header'}
<title>申请{php echo $this->set['texts']['withdraw']}</title>
<style type="text/css">
    body {
        margin: 0;
        background: #efefef;
        -moz-appearance: none;
        overflow: hidden;
    }

    input {
        -webkit-appearance: none;
        outline: none;
    }

    .balance_img {
        height: 80px;
        width: 80px;
        margin: 70px auto 0;
        background: #ffb400;
        border-radius: 40px;
        color: #fff;
        font-size: 70px;
        text-align: center;
        line-height: 90px;
    }

    .balance_text {
        height: 20px;
        width: 100%;
        margin-top: 16px;
        text-align: center;
        line-height: 20px;
        font-size: 16px;
        color: #666;
    }

    .balance_num {
        height: 24px;
        width: 100%;
        margin-top: 10px;
        text-align: center;
        line-height: 24px;
        font-size: 22px;
        color: #444;
    }

    .balance_sub1 {
        height: 44px;
        width: 94%;
        margin: 14px 3% 0;
        background: #ff6600;
        border-radius: 4px;
        text-align: center;
        font-size: 18px;
        line-height: 44px;
        color: #fff;
        box-shadow: #eee 1px 1px 3px;
    }

    .balance_sub2 {
        height: 44px;
        width: 94%;
        margin: 14px 3% 0;
        background: #31cd00;
        border-radius: 4px;
        text-align: center;
        font-size: 18px;
        line-height: 44px;
        color: #fff;
    }

    .balance_sub3 {
        height: 44px;
        width: 94%;
        margin: 14px 3% 0;
        background: #ffffff;
        border-radius: 4px;
        text-align: center;
        font-size: 18px;
        line-height: 44px;
        color: #666;
        box-shadow: #eee 1px 1px 3px;
    }

    .disabled {
        background: #ccc;
    }
</style>
<div id='container'></div>

<script id='tpl_main' type='text/html'>
 <div class="balance_img"><i class="fa fa-cny"></i></div>
    <div class="balance_text">我的{php echo $this->set['texts']['commission_ok']}</div>
    <div class="balance_num">￥<%commission_ok%></div>
    <%if payset.credit != 0%>
    <div class="balance_sub balance_sub1 <%if !cansettle%>disabled<%/if%>" data-type="0">{php echo $this->set['texts']['withdraw']}到余额</div>
    <%/if%>

    <%if payset.weixin != 0%>
    <div class="balance_sub balance_sub2 <%if !cansettle%>disabled<%/if%>"  data-type="1">{php echo $this->set['texts']['withdraw']}到微信</div>
    <%/if%>
    <div class="balance_sub3" onclick="location.href='{php echo $this->createPluginMobileUrl('commission/log')}'">{php echo $this->set['texts']['withdraw']}记录</div>
</script>

<script id='tpl_show_message' type='text/html'><div class="sweet-alert" style="display:block;">
<%if type=='error'%><div class="icon error animateErrorIcon" style="display: block;"><span class="x-mark animateXMark"><span class="line left"></span><span class="line right"></span></span></div><%/if%>
<%if type=='warning'%><div class="icon warning pulseWarning" style="display: block;"><span class="body pulseWarningIns"></span><span class="dot pulseWarningIns"></span></div><%/if%>
<%if type=='success'%><div class="icon success animate" style="display: block;"><span class="line tip animateSuccessTip"></span><span class="line long animateSuccessLong"></span><div class="placeholder"></div><div class="fix"></div></div><%/if%>
<div class="info"><%message%><%if url%><br><span>如果您的浏览器没有自动跳转请点击此处</span><%/if%></div>

<div class="sub" <%if url%>onclick="location.href='<%url%>'"<%else%>history.back()<%/if%>>
<%if type=='success'%><div class="green">确认</div><%/if%>
<%if type=='warning'%><div class="grey">确认</div><%/if%>
<%if type=='error'%><div class="red">确认</div><%/if%>
</div>
</script>

<script language="javascript">
    require(['tpl', 'core'], function(tpl, core) {

        core.pjson('commission/apply',{},function(json){

            console.log(json.result);

           var result = json.result;

           $('#container').html(  tpl('tpl_main',json.result) );
           if(result.noinfo){
                core.message('请补充您的资料后才能申请提现!',result.infourl,'warning');
                return;
            }

           if(json.result.cansettle){
               $('.balance_sub').click(function(){
                   if($('.balance_sub').attr('saving')=='1'){
                       return;
                   }
                   var type= $(this).data('type');

                   core.tip.confirm('确认要申请{php echo $this->set["texts"]["widthdraw"]}? {php echo $this->set["texts"]["withdraw"]}申请通过之后给您打款后会通知您到的微信.',function(){
                       $('.balance_sub').attr('saving',1).html('正在处理中...');

                        core.pjson('commission/apply',{type:type},function(pjson){
                              if(pjson.status=='1'){
                                   core.tip.show( pjson.result );
                                   location.href = "{php echo $this->createPluginMobileUrl('commission/log')}";
                              }
                       },true,true);

                   });
               })
           }
        },true);

    })
</script>
{template 'common/footer'}
